package xyz.sunne.controller;
/**
 * @Author Sunne
 * @Date 2018/8/21/02113:44
 * @Param qccfweb
 * 高山仰止,景行行止.虽不能至,心向往之。
 **/

import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 *——————————————————————————女神保佑，永无bug——————————————————————
 *
 *                    .::::.
 *                  .::::::::.
 *                 :::::::::::  FUCK YOU
 *             ..:::::::::::'
 *           '::::::::::::'
 *             .::::::::::
 *        '::::::::::::::..
 *             ..::::::::::::.
 *           ``::::::::::::::::
 *            ::::``:::::::::'        .:::.
 *           ::::'   ':::::'       .::::::::.
 *         .::::'      ::::     .:::::::'::::.
 *        .:::'       :::::  .:::::::::' ':::::.
 *       .::'        :::::.:::::::::'      ':::::.
 *      .::'         ::::::::::::::'         ``::::.
 *  ...:::           ::::::::::::'              ``::.
 * ```` ':.          ':::::::::'                  ::::..
 *                    '.:::::'                    ':'````..
 */

@RestController
@RequestMapping("user")
public class UserController {
    private final Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("getById")
    public ResponseResult<SysUser> getUserById(String userId) {


        JSONObject jsonObj = new JSONObject();

        jsonObj.put("id", "12");

        String url = "http://microservice-qccf/sys/selectall";

        HttpEntity formEntity = HttpUtils.postJson(jsonObj);

        ResponseResult<SysUser> re = new ResponseResult<SysUser>();

        ResponseResult<SysUser> result =  restTemplate.postForEntity(url,formEntity,re.getClass()).getBody();

        return result;

    }
}
